<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>增减积分</title>
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/css/uploadifive.css">
    <link type="text/css" rel="stylesheet" href="/js/plugins/layer/laydate/skins/default/laydate.css" id="LayDateSkin">
</head>
<br>
<div class="form-group" style="display: inline-block;height: auto">
    <div class="form-group col-md-12">
        <label class="form-label col-md-2">手机号</label>
        <div class="col-md-5">
            <input type="tel" class="form-control" required="required" id="phone" placeholder="请输入手机号">
        </div>
    </div>
    <div class="form-group col-md-12">
        <label class="form-label col-md-2">积分</label>
        <div class="col-md-2">
            <input type="number" class="form-control" required="required" id="mark" placeholder="请输入积分">
        </div>
    </div>
    <div class="form-group col-md-12">
        <label class="form-label col-md-2">备注</label>
        <div class="col-md-8">
            <input type="text" class="form-control" required="required" id="reason" placeholder="请输入备注">
        </div>
    </div>
    <button class="btn btn-info" style="margin-right: 100px;margin-left: 20px;" onclick="handleAdd()">增加</button>
    <button class="btn btn-info" onclick="handleReduce()">减少</button>
</div>
</br>

<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>
<script>
    function handleAdd() {
        var phone=$("#phone").val();
        var mark=$("#mark").val();
        var reason=$("#reason").val();

        if (phone=="" || reason=="" || mark==""){
            swal("分数或者备注不可为空!", "");
            return;
        }
        $.post("/users/addmark",{"phone":phone,"mark":mark,"reason":reason,"add":"1"},function(result){
            if (result.Code==1){
                swal({title: "增加积分成功!",
                    text: ""},function () {
                    location.reload();
                });
            }else{
                swal("操作失败!", result.Data);
            }
        });
    }

    function handleReduce() {
        var phone=$("#phone").val();
        var mark=$("#mark").val();
        var reason=$("#reason").val();

        if (phone=="" || reason=="" || mark==""){
            swal("分数或者备注不可为空!", "");
            return;
        }
        $.post("/users/addmark",{"phone":phone,"mark":mark,"reason":reason,"add":"0"},function(result){
            if (result.Code==1){
                swal({title: "减少积分成功!",
                    text: ""},function () {
                    location.reload();
                });
            }else{
                swal("操作失败!", result.Data);
            }
        });
    }

</script>
</body>
</html>